import asyncio
from playwright.async_api import async_playwright


# 定义一个异步函数main作为程序的入口点
async def main():
    async with async_playwright() as p:
        browser = await p.chromium.launch()
        page = await browser.new_page()
        await page.goto("https://www.baidu.com/")
        print(await page.title())
        await browser.close()


# 使用asyncio库的run函数来运行main函数，这是启动整个程序的命令
# Execute the coroutine and return the result.
asyncio.run(main())
